<extend name="./Public/base" />
<block name="title">个人中心</block>
<block name="head">
    <load href="__PUBLIC__/Css/info.css"/>
</block>

<block name="header">
    <include file="Application/Home/View/Public/header_tea.html"/>
</block>
<block name="main">
    <div class="container" id="container">
        <div class="row">
            <div class="col-md-offset-2 col-md-8 margin-bottom-10">
                <div class="alert alert-danger hidden" role="alert"></div>
                <nav class="nav nav-pills">
                    <li class="active"><a href="__MODULE__/TeaSettings/info">基本资料</a></li>
                    <li><a href="__MODULE__/TeaSettings/change_pwd">密码管理</a></li>
                </nav>
            </div>
        </div>
        <div class="row">
            <div class="col-md-offset-2 col-md-8">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-4">
                            <ul class="list-inline">
                                <li><b>邮箱:</b></li>
                                <li>{$info.tea_email}</li>
                            </ul>
                            </div>
                        </div>
                        <div class="row" id="name">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>姓名:</label></li>
                                    <li><input class="form-control" type="text" value="{$info.tea_name}" required
                                        placeholder="请输入姓名">
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="row" id="sex">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>性别:</label></li>
                                    <label class="radio-inline">
                                        <input type="radio" value="男" name="sex"<if condition="$info.sex eq '男'">checked="checked"</if>>男性
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" value="女" name="sex" <if condition="$info.sex eq '女'">checked="checked"</if>>女性
                                    </label>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>机构:</label></li>
                                    <li>{$info.col_name}</li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>身份:</label></li>
                                    <li>{$info.state}</li>
                                </ul>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <if condition="$info.state eq '教师'">
                                        <li><label>教工号:</label></li>
                                        <else/>
                                        <li><label>学号:</label></li>
                                    </if>
                                    <li>{$info.tea_number}</li>
                                </ul>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-11">
                                <button id="modified" class="btn btn-primary">修改</button>
                                <label style="display:none; color:red" id="message"></label>
                            </div>
                            <input type="hidden" id="url" value="__MODULE__"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function(){
            var name = $("#name input");
            var sex = $("#sex input:checked");

            $("#modified").click(function(e){        
                $(this).blur();
                var name_input = name.val();
                var sex_input = $("#sex input:checked").val();
                if (name_input !== "") {
                    postApi("__MODULE__/TeaSettings/Update_tea_info", {tea_name:name_input,sex:sex_input},
                        function(err, data) {
                            if (err) {
                                showError(err.message);
                            } else {
                                $("#message").html("修改成功");
                                $("#message").fadeIn("fast");// 弹出;
                                $("#message").fadeOut(2000); //变淡消失
                                //setTimeout("$('#message').hide()",3000);
                                setTimeout(" window.location.href=$('#url').val()+'/TeaSettings/info'",1000);
                            }
                        });
                }

                if (name_input === "") {
                    showError("姓名不能为空");
                    name.focus();
                }
            });
        });
    </script>
</block>